package com.kaikeba.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kaikeba.bean.Admin;
import com.kaikeba.bean.Student;
import com.kaikeba.mapper.AdminMapper;
import com.kaikeba.service.AdminService;
import com.kaikeba.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    @Qualifier(value = "adminMapper")
    private AdminMapper adminMapper;

    @Override
    public Admin selectByAccountAndPassword(Admin admin) {
        return adminMapper.selectByAccountAndPassword(admin);
    }

    @Override
    public PageInfo<Student> findAllStu(int index,Integer gradeid,String studentno,String stuname) {

        PageHelper.startPage(index, PageUtil.PAGESIZE);
        Map map = new HashMap();
        map.put("gradeid",gradeid);
        map.put("studentno",studentno);
        map.put("stuname",stuname);
        List<Student> students = adminMapper.findAllStu(map);
        PageInfo pageInfo = new PageInfo(students);
        return pageInfo;
    }
}
